<template>
  <div class="content-wrapper">
    <div class="content-header">打印表格</div>
    <div class="content-container">
      <el-form :inline="true" :model="listQuery" class="filter-container">
        <el-form-item label="表格名称">
          <el-input
            type="text"
            size="mini"
            v-model="listQuery.name"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            class="filter-item"
            size="small"
            round
            type="primary"
            icon="el-icon-search"
          >
            搜索
          </el-button>
        </el-form-item>
      </el-form>
      <div>
        <el-table
          height="500"
          v-loading="listLoading"
          :data="dataList"
          highlight-current-row
          style="width: 100%"
        >
          <el-table-column label="表格名称" min-width="200">
            <template slot-scope="scope">
              <span style="cursor: pointer">{{ scope.row.documentName }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="version" label="版本" width="160px" />
          <!-- <el-table-column prop="version" label="修改人" width="160px" /> -->
          <el-table-column prop="updateTime" label="修改时间" width="160px" />
          <!-- <el-table-column  prop="version" label="打印次数" width="100px" />
          <el-table-column prop="version" label="打印人" width="160px" />
          <el-table-column prop="version" label="打印时间" width="160px" /> -->
          <el-table-column
            label="操作"
            align="center"
            width="150px"
            fixed="right"
          >
            <template slot-scope="{ row }">
              <el-dropdown trigger="click" class="filter-item">
                <el-button type="text" class="el-icon-more" />
                <el-dropdown-menu slot="dropdown" class="user-dropdown">
                  <el-dropdown-item  @click.native="view(row)">预览打印</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <pagination
        v-show="total > 0"
        :total="total"
        :page-number.sync="listQuery.pageNumber"
        :page-size.sync="listQuery.pageSize"
        @pagination="getDataList"
      />
    </div>
  </div>
</template>
<script>

import Pagination from '@/components/Pagination'
import { pagePrintList } from '@/api/rs/record_template'
export default {
  components: {
    Pagination
  },
  data() {
    return {
      listLoading: false,
      dataList: [],
      listQuery: {
        pageNumber: 1,
        pageIndex: 0,
        pageSize: 10
      },
      total: 999
    }
  },
  mounted() {
    this.getDataList()
  },
  methods: {
    getDataList() {
    //   this.listLoading = true
      this.listQuery.pageIndex = this.listQuery.pageNumber - 1
      pagePrintList(this.listQuery).then(res => {
        console.log(res);
        this.dataList = res.data.rows
        this.total = res.data.total
      })
    },
        view(row) {
      window.open(
        'onlyoffice/createDocument.html?&token=' +
          this.$store.getters.token +
          '&documentId=' +
          row.documentId +
          '&mode=view' + '&urldata=' + process.env.VUE_APP_BASE_API
      )
    },
  }
}
</script>
